package com.coolham.switter;

import com.coolham.switter.R;

import weibo4andriod.Weibo;
import weibo4andriod.WeiboException;
import weibo4andriod.http.RequestToken;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.RadioGroup;

public class AccessTokenActivity extends Activity {
	final static String TAG = "FirstTab";

	private RadioGroup mRadios;
	private Button testBtn;

	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		setContentView(R.layout.first_tab);
		
		Button beginOuathBtn = (Button) findViewById(R.id.Button01);

		beginOuathBtn.setOnClickListener(new Button.OnClickListener() {

			@Override
			public void onClick(View v) {
				Weibo weibo = OAuthConstant.getInstance().getWeibo();
				RequestToken requestToken;
				try {
					requestToken = weibo
							.getOAuthRequestToken("com.coolham.switter://OAuthActivity");
					Uri uri = Uri.parse(requestToken.getAuthenticationURL()
							+ "&from=xweibo");
					OAuthConstant.getInstance().setRequestToken(requestToken);
					startActivity(new Intent(Intent.ACTION_VIEW, uri));
				} catch (WeiboException e) {
					e.printStackTrace();
				}

			}
		});
	}
}
